package com.lagou.edu.controller;

import com.lagou.edu.pojo.Resume;
import com.lagou.edu.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/resume")
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/list")
    public String list(ModelMap modelMap) {
        modelMap.addAttribute("list",resumeService.findAll());
        return "index";
    }

    @RequestMapping("/findOne")
    public String findOne(ModelMap modelMap,Long id) {
        modelMap.addAttribute("item",resumeService.findById(id));
        return "update";
    }

    @RequestMapping("/save")
    public String save(Resume resume) {
        resumeService.save(resume);
        return "success";
    }

    @RequestMapping("/update")
    public String update(Resume resume) {
        resumeService.update(resume);
        return "success";
    }

    @RequestMapping("/delete")
    public String delete(Long id){
        resumeService.delete(id);
        return "success";
    }

}
